<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import backendDeviceType from '@/api/backend/deviceType.js'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()




const options = reactive({
  id: 'backend_device_type',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: backendDeviceType.getList,
  add: {
    show: true,
    api: backendDeviceType.save,
    auth: ['deviceType:save']
  },
  edit: {
    show: true,
    api: backendDeviceType.update,
    auth: ['deviceType:update']
  },
  delete: {
    show: true,
    api: backendDeviceType.deletes,
    auth: ['deviceType:delete']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "设备类型",
    dataIndex: "device_type",
    formType: "select",
    multiple: false,
    dict: {
      name: 'device_type',
      props: {label: 'title', value: 'key'},
      translation: true
    },
  },
  {
    title: "名称",
    dataIndex: "name",
    formType: "input"
  },
  {
    title: "描述",
    dataIndex: "desc",
    formType: "input"
  },
  {
    title: "图片",
    dataIndex: "image",
    formType: "upload",
    type: "image",
    multiple: false
  },
  {
    title: "售后电话",
    dataIndex: "phone",
    formType: "input"
  }
])
</script>
<script> export default { name: 'deviceType' } </script>